<template>
  <el-button type="primary" @click="dialogTableVisible = true">从资源库中选择文件</el-button>
  <el-dialog v-model="dialogTableVisible" title="资源库">
    <el-table @selection-change="handleSelectionChange" :data="tableData" height="250" style="width: 100%">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="CreatedAt" label="创建时间" width="180"/>
      <el-table-column prop="name" label="资源名称" width="180"/>
      <el-table-column prop="url" label="url"/>
    </el-table>
    <el-button type="primary" @click="putListToFile">选择</el-button>
  </el-dialog>
</template>

<script>
import axios from "axios";
export default {
  emits:["putList"],
  name: "DataSpace",
  created() {
    axios.post("/api/GetAllFileList").then((res)=>{
      if (res.status===200){
        this.tableData = res.data
      }
    })
  },
  methods:{
    handleSelectionChange(val){
      this.multipleSelection = val
    },
    putListToFile(){
      this.$emit("putList",this.multipleSelection)
      this.dialogTableVisible = false
    }
  },
  data() {
    return {
      multipleSelection: [],
      dialogTableVisible: false,
      tableData: [],
    }
  }
}
</script>

<style scoped>

</style>